<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script src="js/jquery-3.4.1.min.js"></script>
    <style>
        .red{
            height: 100px;
            width: 100px;
            background:red;
        }
        .blue{
            height: 100px;
            width: 100px;
            background:blue;
        }
    </style>
</head>
<body>
    <div class="red"></div>
    <button>切换</button>
    <script>
        $(function(){
            $('button').click(function(){
                $('div').toggleClass('blue')
            })
        })
    </script>
</body>
</html>